import { Language } from "../../../../../../extend/language/Language";
import { ObjCreate } from "../../../common/ObjCreate";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { FontUtil } from "../../../../../common/font/FontUtil";
import { DomWarConst } from "../../DomWarConst";
import { DominionId } from "../../../../../../Message/Public/DominionId";
//class UnionInfoContentSpite
    
    export  class UnionInfoContentSpite /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.createUI();
            return;
        }

        /* internal  */createUI(): void
        {
            this._markBmp = new Object /* flash.display.Bitmap */();
            this.addChild(this._markBmp);
            this._markBmp.x = -86;
            this._markBmp.y = -18;
            this._mainSerTxt = this.getTextField(-45, -18);
            this._mainSerTxt.width = 135;
            this._mainSerTxt.autoSize = "left";
            this._mainSerTxt.text = Language.getString(80500);
            this._nationPowerBmp1 = new Object /* flash.display.Bitmap */();
            this.addChild(this._nationPowerBmp1);
            this._nationPowerBmp1.x = -51;
            this._nationPowerBmp1.y = 2;
            this._nationPowertxt0 = ObjCreate.createGTextField("", this._nationPowerBmp1.x + 60, this._nationPowerBmp1.y, 100, 20, this, GlobalStyle.textFormat5);
            this._nationPowertxt0.autoSize = "left";
            this._unionSerTxt1 = this.getTextField(-117, 25);
            this._unionSerTxt1.text = "";
            this._nationPowerBmp2 = new Object /* flash.display.Bitmap */();
            this.addChild(this._nationPowerBmp2);
            this._nationPowerBmp2.x = this._unionSerTxt1.x;
            this._nationPowerBmp2.y = 45;
            this._nationPowertxt1 = ObjCreate.createGTextField("", this._nationPowerBmp2.x + 60, this._nationPowerBmp2.y, 100, 20, this, GlobalStyle.textFormat5);
            this._nationPowertxt1.autoSize = "left";
            this._inviteBmp2 = new Object /* flash.display.Bitmap */();
            this.addChild(this._inviteBmp2);
            this._inviteBmp2.x = this._unionSerTxt1.x + 30;
            this._inviteBmp2.y = this._unionSerTxt1.y;
            this._inviteBmp2.visible = false;
            this._unionSerTxt2 = this.getTextField(23, 25);
            this._unionSerTxt2.text = "";
            this._nationPowerBmp3 = new Object /* flash.display.Bitmap */();
            this.addChild(this._nationPowerBmp3);
            this._nationPowerBmp3.x = this._unionSerTxt2.x;
            this._nationPowerBmp3.y = 45;
            this._nationPowertxt2 = ObjCreate.createGTextField("", this._nationPowerBmp3.x + 60, this._nationPowerBmp3.y, 100, 20, this, GlobalStyle.textFormat5);
            this._nationPowertxt2.autoSize = "left";
            this._inviteBmp3 = new Object /* flash.display.Bitmap */();
            this.addChild(this._inviteBmp3);
            this._inviteBmp3.x = this._unionSerTxt2.x + 30;
            this._inviteBmp3.y = this._unionSerTxt2.y;
            this._inviteBmp3.visible = false;
            LoaderHelp.addResCallBack(ResFileConst.dominionWarBeacon, this.onLoaded);
            return;
        }

        /* internal  */onLoaded(): void
        {
            this._isLoaded = true;
            this._nationPowerBmp1.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_nationPower);
            this._nationPowerBmp2.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_nationPower);
            this._nationPowerBmp3.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_nationPower);
            this._inviteBmp2.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_inviteUnion);
            this._inviteBmp3.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_inviteUnion);
            this.setMarkBmp();
            return;
        }

        /* internal  */getTextField(arg1: number, arg2: number): GTextFiled
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 14, GlobalStyle.color6Uint, null, null, null, null, null, flash.text.TextFormatAlign.LEFT);
            var loc2;
            (loc2 = ObjCreate.createGTextField("", arg1, arg2, 100, 20, this, loc1)).autoSize = "left";
            loc2.filters = [new Object /* flash.filters.GlowFilter */(11413025, 1, 2, 2, 3, 3)];
            return loc2;
        }

        public updateInfo(arg1: Object, arg2: Boolean=false): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=NaN;
            var loc4=undefined;
            this._isUpdate = true;
            this._isAtk = arg2;
            this.setMarkBmp();
            if (arg1) 
            {
                loc1 = arg1.assistIds;
                this._mainSerTxt.text = DomWarConst.getSerNameByDomId(arg1.mainId);
                this._nationPowertxt0.text = arg1.combat.toString();
                loc2 = 0;
                var loc5=0;
                var loc6=loc1;
                for (loc4 in loc6) 
                {
                    ++loc2;
                    loc3 = loc1[loc4];
                    this["_nationPowertxt" + loc2].text = loc3.toString();
                    this["_unionSerTxt" + loc2].text = DomWarConst.getSerNameByDomId(loc4 as DominionId);
                }
            }
            return;
        }

        /* internal  */setMarkBmp(): void
        {
            if (this._isLoaded && this._isUpdate) 
            {
                if (this._isAtk) 
                {
                    this._markBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DomWarBea_swordBig);
                }
                else 
                {
                    this._markBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DomWarBea_shieldBig);
                }
            }
            return;
        }

        /* internal */ /* const */NO_UNION_TXT: string="———";

        /* internal */ /* var */_mainSerTxt: GTextFiled;

        /* internal */ /* var */_unionSerTxt1: GTextFiled;

        /* internal */ /* var */_unionSerTxt2: GTextFiled;

        /* internal */ /* var */_nationPowertxt0: GTextFiled;

        /* internal */ /* var */_nationPowertxt1: GTextFiled;

        /* internal */ /* var */_nationPowertxt2: GTextFiled;

        /* internal */ /* var */_nationPowerBmp1: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nationPowerBmp2: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nationPowerBmp3: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_inviteBmp2: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_inviteBmp3: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_markBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isLoaded: Boolean;

        /* internal */ /* var */_isUpdate: Boolean;

        /* internal */ /* var */_isAtk: Boolean;
    }
